%% build the mex-cpp file by mex command

OpenCV_INCLUDE_DIRS =   {['-I/opt/ros/kinetic/include/opencv-3.3.1-dev'], ...
                        ['-I/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv']};
PCL_INCLUDE_DIRS = {
    '-I/usr/include/pcl-1.7', ...
    '-I/usr/include/eigen3', ...
    '-I/usr/include', ...
    '-I/usr/include/ni', ...
    '-I/usr/include/openni2', ...
    '-I/usr/include/vtk-6.2', ...
    '-I/usr/include/freetype2', ...
    '-I/usr/include/x86_64-linux-gnu/freetype2', ...
    '-I/usr/include/jsoncpp', ...
    '-I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent', ...
    '-I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include', ...
    '-I/usr/lib/openmpi/include;/usr/lib/openmpi/include/openmpi', ...
    '-I/usr/include/python2.7', ...
    '-I/usr/include/x86_64-linux-gnu', ...
    '-I/usr/include/hdf5/openmpi', ...
    '-I/usr/include/libxml2', ...
    '-I/usr/include/tcl', ...
};
OpenCV_LIBRARY_DIRS = {
    ['-L','/usr/local/lib'], ...
    ['-L','/usr/lib/x86_64-linux-gnu'], ...
    ['-L','/lib/x86_64-linux-gnu'], ...
};

OpenCV_LIBRARIES = {
    ['-l','opencv_core.so'], ...
};

%% ======================================================================================== %%
disp('=====================================================================================');
disp('build function groundRemovalMex');
disp('=====================================================================================');
opts = {
    % ['-DDEBUG '], ...
};
src = {
    ['./cpp/groundRemovalMex.cpp'], ...
};
mex(...
    opts{:}, ...
    src{:}, ...
    '-outdir', ...
    './mex'); 

%% ======================================================================================== %%
disp('=====================================================================================');
disp('build function projectPointCloudMex');
disp('=====================================================================================');
opts = {
    % ['-DDEBUG '], ...
};
src = {
    ['./cpp/projectPointCloudMex.cpp'], ...
};
mex(...
    opts{:}, ...
    src{:}, ...
    '-outdir', ...
    './mex'); 

%% ======================================================================================== %%
disp('=====================================================================================');
disp('build function cloudSegmentationMex');
disp('=====================================================================================');
opts = {
    % ['-DDEBUG '], ...
    % ['-std=c++11 '], ...
    ['-D_GLIBCXX_USE_CXX11_ABI=0 '], ...
};
src = {
    ['cpp/cloudSegmentation.cpp'], ...
    ['cpp/cloudSegmentationMex.cpp'], ...
};
mex(...
    opts{:}, ...
    src{:}, ...
    PCL_INCLUDE_DIRS{:}, ...
    OpenCV_INCLUDE_DIRS{:}, ...
    OpenCV_LIBRARY_DIRS{:}, ...
    OpenCV_LIBRARIES{:}, ...
    '-outdir', ...
    './mex', ...
    '-output', ...
    'cloudSegmentationMex'); 